package com.undefind;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;

public class NGuessNumber {
    int[] answer;
    public int[] generateAnswer(){
        Random random = new Random();
        int[] answers = new int[4];
        answers[0] = random.nextInt(0,9);
        answers[1] = random.nextInt(0,9);
        answers[2] = random.nextInt(0,9);
        answers[3] = random.nextInt(0,9);
        answer = answers;
        return answers;
    }
    public int[] getPlayerInput(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入猜测的数字");
        int[] result = new int[4];
        result[0] = sc.nextInt();
        result[1] = sc.nextInt();
        result[2] = sc.nextInt();
        result[3] = sc.nextInt();
        return result;
    }
    public  Map<Integer,Boolean> compareGuessAnswer(int[] answer,int[] input){
        Map<Integer,Boolean> result = new HashMap<>();
        for (int i = 0;i<answer.length;i++){
            if (answer[i] == input[i]){
                result.put(answer[i],true);
            }else{
                result.put(answer[i],false);
            }
        }
        return result;
    }
    public boolean isWin( Map<Integer,Boolean> result){
        for (boolean b:
                result.values()) {
            if(b == false){
                return  false;
            }
        }
        return true;
    }
}
